﻿@model IEnumerable<TGBTech.Core.Models.ChungTu.ChungTu>

@{
    ViewBag.Title = "Index";
}
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption">Danh sách tài khoản</div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                    <a href="#portlet-config" data-toggle="modal" class="config"></a>
                    <a href="javascript:;" class="reload"></a>
                </div>
            </div>
            <div class="portlet-body">
                <div class="table-toolbar">
                    <div class="btn-group">
                        @using (Html.BeginForm("Create", "ChungTu", FormMethod.Get))
                        {
                            <button id="sample_editable_1_new" class="btn green" type="submit">
                                Thêm mới <i class="icon-plus"></i>

                            </button>
                        }
                    </div>
                    <div class="btn-group pull-right">
                        <button class="btn dropdown-toggle" data-toggle="dropdown">
                            Công cụ <i class="icon-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="#">In</a></li>
                            <li><a href="#">Lưu thành PDF</a></li>
                            <li><a href="#">Xuất ra Excel</a></li>
                        </ul>
                    </div>
                </div>
                <table class="table table-striped table-bordered table-hover" id="tableChungTu">
                    <thead>
                        <tr>
                            <th class="table-checkbox"><input type="checkbox" class="group-checkable" data-set="#tableChungTu .checkboxes" /></th>
                            <th><b>Số CT</b></th>
                            <th><b>Ngày CT</b></th>
                            <th><b>Nợ</b></th>
                            <th><b>Có</b></th>
                            <th><b>Lý do</b></th>
                            <th><b>Mã KH</b></th>
                            <th><b>Số hiệu</b></th>
                            <th><b>Số HĐ</b></th>
                            <th><b>Ngày HĐ</b></th>
                            <th></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr class="odd gradeX">
                                <td><input type="checkbox" class="checkboxes" value="1" /></td>
                                <td>@item.Id</td>
                                <td>@item.NgayCT</td>
                                <td>@item.TaiKhoanNo.Id</td>
                                <td>@item.TaiKhoanCoId</td>
                                <td>@item.LyDoNhapXuat</td>
                                <td>@item.KhachHangId</td>
                                <td>@item.SoHieu</td>
                                <td>@item.SoHoaDon</td>
                                <td>@item.NgayHoaDon</td>
                                <td>@Html.ActionLink("Sửa", "Edit", new { id = item.Id })</td>
                                <td>@Html.ActionLink("Xóa", "Delete", new { id = item.Id })</td>
                            </tr>
                        }

                    </tbody>
                </table>
            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>
</div>


<script>
    $(document).ready(function () {
        if (!jQuery().dataTable) {
            return;
        }

        // begin first table
        $('#tableChungTu').dataTable({
            "aoColumns": [
              { "bSortable": false },
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              { "bSortable": false },
              { "bSortable": false }
            ],
            "aLengthMenu": [
                [10, 25, 50, -1],
                [10, 25, 50, "Tất cả"] // change per page values here
            ],
            // set the initial value
            "iDisplayLength": 10,
            "sPaginationType": "bootstrap",
            "oLanguage": {
                "sLengthMenu": "_MENU_ dòng",
                "oPaginate": {
                    "sPrevious": "Prev",
                    "sNext": "Next"
                }
            },
            "aoColumnDefs": [{
                'bSortable': false,
                'aTargets': [0]
            }
            ]
        });

        jQuery('#tableChungTu .group-checkable').change(function () {
            var set = jQuery(this).attr("data-set");
            var checked = jQuery(this).is(":checked");
            jQuery(set).each(function () {
                if (checked) {
                    $(this).attr("checked", true);
                } else {
                    $(this).attr("checked", false);
                }
                $(this).parents('tr').toggleClass("active");
            });
            jQuery.uniform.update(set);

        });

        jQuery('#tableChungTu tbody tr .checkboxes').change(function () {
            $(this).parents('tr').toggleClass("active");
        });

        jQuery('#tableChungTu_wrapper .dataTables_filter input').addClass("form-control input-medium"); // modify table search input
        jQuery('#tableChungTu_wrapper .dataTables_length select').addClass("form-control input-small"); // modify table per page dropdown
        //jQuery('#sample_1_wrapper .dataTables_length select').select2(); // initialize select2 dropdown
    });
</script>